package flc.ast.utils;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import flc.ast.bean.PracticeTime;

@Database(entities = {PracticeTime.class}, version = 2, exportSchema = false)
public abstract class PracticeDatabase extends RoomDatabase {
    //暴露Dao
    public abstract PracticeDao getPracticeDao();
    private static PracticeDatabase INSTANCE;
    public static synchronized PracticeDatabase getInstance(Context context){
        if(INSTANCE == null){
            INSTANCE = Room.databaseBuilder
                    (context.getApplicationContext(),
                    PracticeDatabase.class, "practice_database")
                    .allowMainThreadQueries()
                    .build();
        }
        return INSTANCE;
    }
}

